home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / utils / file / logiso.000 / logiso / Utils / RCS / process_lists.c,v < prev    next >
Encoding:
Text File  |  1995-03-24  |  2.6 KB  |  121 lines

  1. head    1.2;
  2. access;
  3. symbols
  4.     VER_0_3:1.2
  5.     VER_0_2:1.1;
  6. locks; strict;
  7. comment    @ * @;
  8.  
  9.  
  10. 1.2
  11. date    95.03.24.11.43.35;    author coulter;    state Exp;
  12. branches;
  13. next    1.1;
  14.  
  15. 1.1
  16. date    95.02.18.08.36.38;    author coulter;    state Exp;
  17. branches;
  18. next    ;
  19.  
  20.  
  21. desc
  22. @process a list of inodes and cd_files to make a list like last_install
  23. @
  24.  
  25.  
  26. 1.2
  27. log
  28. @Checkin version for 0.3 distribution.
  29. @
  30. text
  31. @
  32. /* process_lists.c
  33.    USAGE: process_lists       inode_list_file    pair_list_file
  34.        inode list file is a file with one inode number on each line,
  35.            sorted numerically (ascending).  Should be run through uniq
  36.            also.
  37.         pair_list_file is a file with an inode number followed by a space
  38.             and a file path on each line.  It is also sorted
  39.             numerically (ascending).
  40.  
  41.         For each inode number which appears in both files, print the
  42.             file path from the pair_list_file.
  43.  
  44. */
  45. /* (C) Copyright 1995 by Michael Coulter.  All rights reserved. */
  46.  
  47. #include <stdio.h>
  48. #include <stdlib.h>
  49.  
  50. extern void print_usage();
  51.  
  52. #define FALSE        0
  53. #define TRUE         1
  54. #define MAX_FILE_PATH    2000
  55.  
  56. main(int argc, char** argv)
  57. {
  58.    char        file_path[MAX_FILE_PATH];
  59.    FILE*     inode_list_fp;
  60.    long int    inode1_nbr;
  61.    long int    inode2_nbr;
  62.    int        is_more_input;
  63.    FILE*     pair_list_fp;
  64.    int        result;
  65.  
  66.    if (argc != 3) {
  67.       print_usage();
  68.       exit(1);
  69.    }
  70.    if ((inode_list_fp = fopen(argv[1], "r") ) == NULL) {
  71.       print_usage();
  72.       fprintf(stderr, "Unable to open %s\n", argv[1]);
  73.       exit(1);
  74.    }
  75.    if ((pair_list_fp = fopen(argv[2], "r") ) == NULL) {
  76.       print_usage();
  77.       fprintf(stderr, "Unable to open %s\n", argv[2]);
  78.       exit(1);
  79.    }
  80.  
  81.    is_more_input = TRUE;
  82.    inode1_nbr = inode2_nbr = 0;
  83.    while (is_more_input) {
  84.       if (   inode1_nbr <= inode2_nbr
  85.           && (result = fscanf(inode_list_fp, "%ld", &inode1_nbr)) != 1) 
  86.       {
  87.          is_more_input = FALSE;
  88.       } else {
  89.      if (   inode2_nbr < inode1_nbr 
  90.          && (result = fscanf(pair_list_fp, "%ld %s", &inode2_nbr, file_path)) 
  91.             != 2) 
  92.          { 
  93.         is_more_input = FALSE;
  94.          } else {
  95.             if (inode1_nbr == inode2_nbr) {
  96.                fprintf(stdout, "%ld        %s\n", inode2_nbr, file_path);
  97.             }
  98.          }
  99.       }
  100.    } /* while input on both files */
  101.  
  102. } /* end main */
  103.  
  104.  
  105. void print_usage()
  106. {
  107.    fprintf(stderr, "USAGE: process_lists inode_list_file pair_list_file\n");
  108.    fprintf(stderr, "One inode number per line in the first file.\n");
  109.    fprintf(stderr, "An inode number and a file path per line in the second.\n");
  110. } /* end print_usage */
  111. @
  112.  
  113.  
  114. 1.1
  115. log
  116. @Checkpoint version before fixing /usr/bin install
  117. @
  118. text
  119. @d15 1
  120. @
  121.